package com.lzxuni.config;

import com.aliyun.oss.OSSClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 〈一句话功能简述〉<br>
 *
 * @author:孙志强
 * @create:2019-01-22 10:19
 * @Modified BY:
 **/
@ConfigurationProperties(prefix = "lzxuni.oss")
@Component
public class OssClientFactory {

	private volatile static OSSClient client;
	private String endpoint;
	private String accessKeyId;
	private String accessKeySecret;
	private String bucketName;
	private Long expireTime;

	public OSSClient getOSSClient() {
		if (client == null) {
			synchronized (OssClientFactory.class) {
				if (client == null) {
					client = new OSSClient(endpoint, accessKeyId, accessKeySecret);
				}
			}
		}
		return client;
	}

	public static OSSClient getClient() {
		return client;
	}

	public static void setClient(OSSClient client) {
		OssClientFactory.client = client;
	}

	public String getEndpoint() {
		return endpoint;
	}

	public void setEndpoint(String endpoint) {
		this.endpoint = endpoint;
	}

	public String getAccessKeyId() {
		return accessKeyId;
	}

	public void setAccessKeyId(String accessKeyId) {
		this.accessKeyId = accessKeyId;
	}

	public String getAccessKeySecret() {
		return accessKeySecret;
	}

	public void setAccessKeySecret(String accessKeySecret) {
		this.accessKeySecret = accessKeySecret;
	}

	public String getBucketName() {
		return bucketName;
	}

	public void setBucketName(String bucketName) {
		this.bucketName = bucketName;
	}

	public Long getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(Long expireTime) {
		this.expireTime = expireTime;
	}
}
